<?php
namespace Peas\Kernel\System\Plugins\Template;

use Peas\Routing\Router;

/**
 * Peas Framework
 *
 * 模板引擎标签扩展：路由标签
 *
 * @author  Hongzan Zhang <zhanghongzan@163.com>
 * @version $Id$
 */
class UrlTag
{
    /**
     * 路由标签
     *
     * @param  Peas\View\Compiler\Compiler $compiler
     * @param  string $tagStr
     * @return string
     */
    public function begin(&$compiler, $tagStr)
    {
        return (strstr($tagStr, '$') !== false) ? '<?php echo \Peas\Routing\Router::createUrl("' . $tagStr . '");?>' : Router::createUrl($tagStr);
    }
}
